Learn R Programming

pracma (version 0.7.5)

erf, erfc: Error Functions (Matlab Style)

Description

The error or Phi function is a variant of the cumulative normal (or Gaussian) distribution.

Usage

erf(x)
erfc(x)

erfz(z)

Arguments

x
vector of real numbers.
z
real or complex number; must be a scalar.

Value

  • Real or complex number, the value of the function. Please note that erfz is not (yet) vectorized.

Details

For real arguments, the following obvious relations $$erf(x) = 2 Phi(x \sqrt(2)) - 1$$ $$erfc(x) = 2 Phi(-x \sqrt(2))$$ for the error and the complementary error functions were used.

See Also

pnorm

Examples

Run this code
x <- 1
  erf(x); 2*pnorm(sqrt(2)*x) - 1
# [1] 0.842700792949715
# [1] 0.842700792949715
  erfc(x); 1 - erf(x); 2*pnorm(-sqrt(2)*x)
# [1] 0.157299207050285
# [1] 0.157299207050285
# [1] 0.157299207050285
  erfz(1)
# [1] 0.842700792949715

Run the code above in your browser using DataLab